#include<gtk-2.0/gtk/gtk.h>
#include<stdio.h>

//variables used in programs
extern GtkWidget *mplayer;
extern GtkWidget *vbox,*hbox;
extern GtkWidget *volumecontrol,*seekbar;
extern GtkWidget *toolbar;
extern GtkToolItem *opentool,*septool1,*playtool,*pausetool,*stoptool,*septool2,*exittool;
extern GtkWidget *menubar;
extern GtkWidget *filemenu,*volumemenu,*playbackmenu,*helpmenu;
extern GtkWidget *file,*open,*quit,*volume,*statusbar,*volumeup,*volumedown,*mute,*sep,*playback,*play,*pause,*stop,*help,*about;
extern GtkWidget *m_player;


GtkWidget* create_mplayer() {
	mplayer = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(mplayer), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(mplayer), 250, 100);
	gtk_window_set_title(GTK_WINDOW(mplayer), "Media Player");

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(mplayer), vbox);

	//Adding Toolbar
	toolbar = gtk_toolbar_new();
	gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
	gtk_container_set_border_width(GTK_CONTAINER(toolbar), 2);

	//Adding open toolbar item
	opentool = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), opentool, -1);

	//Adding a separator in tool bar
	septool1 = gtk_separator_tool_item_new();
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), septool1, -1);

	//Adding Play toolbar item
	playtool = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar),playtool, -1);

	//Adding Pause toolbar item
	pausetool = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PAUSE);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar),pausetool, -1);

	//Adding Stop toolbar item
	stoptool = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_STOP);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar),stoptool, -1);

	//Adding a separator in tool bar
	septool2 = gtk_separator_tool_item_new();
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), septool2, -1);

	//Adding Exit Toolbar item
	exittool = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), exittool, -1);

	//Adding menubar
	menubar = gtk_menu_bar_new();

	//Adding Menus
	filemenu = gtk_menu_new();
//	volumemenu = gtk_menu_new();
	playbackmenu = gtk_menu_new();
	helpmenu = gtk_menu_new();

	//gtk_window_add_accel_group(GTK_WINDOW(mplayer), NULL);

	//Adding Menuitems as Menu
	file = gtk_menu_item_new_with_mnemonic("_File");
	playback = gtk_menu_item_new_with_mnemonic("_Playback");
	//volume = gtk_menu_item_new_with_mnemonic("_Volume");
	help = gtk_menu_item_new_with_mnemonic("_help");

	//Adding File Menu Items like Open,Quit
	open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN,NULL);
	sep = gtk_separator_menu_item_new();
	quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);

	//Adding playback Menu items like play,pause,stop
	play = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PLAY,NULL);
	pause = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PAUSE,NULL);
	stop = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_STOP,NULL);

	//Adding Volume Menu Item like Volume Up, Volume Down, Mute.
//	volumeup = gtk_menu_item_new_with_mnemonic("Volume _Up");
	//volumedown = gtk_menu_item_new_with_mnemonic("Volume _Down");
	//mute = gtk_menu_item_new_with_mnemonic("_Mute");

	//Adding help menu items
	about = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,NULL);

	//Adding Menu items in menu Bar and menu bar in Window
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(playback),playbackmenu);
//	gtk_menu_item_set_submenu(GTK_MENU_ITEM(volume), volumemenu);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(help),helpmenu);

	gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), open);
	gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), sep);
	gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);

	gtk_menu_shell_append(GTK_MENU_SHELL(playbackmenu),play);
	gtk_menu_shell_append(GTK_MENU_SHELL(playbackmenu),pause);
	gtk_menu_shell_append(GTK_MENU_SHELL(playbackmenu),stop);

	//gtk_menu_shell_append(GTK_MENU_SHELL(volumemenu), volumeup);
	//gtk_menu_shell_append(GTK_MENU_SHELL(volumemenu), volumedown);
	//gtk_menu_shell_append(GTK_MENU_SHELL(volumemenu), mute);

	gtk_menu_shell_append(GTK_MENU_SHELL(helpmenu),about);

	gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
	gtk_menu_shell_append(GTK_MENU_SHELL(menubar),playback);
	//gtk_menu_shell_append(GTK_MENU_SHELL(menubar), volume);
	gtk_menu_shell_append(GTK_MENU_SHELL(menubar),help);

	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3);
	gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 5);

	//Adding window item in window
	hbox = gtk_hbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(vbox), hbox);
	seekbar = gtk_hscale_new_with_range(0,100,1);
	gtk_scale_set_digits(GTK_SCALE(seekbar),2);
	gtk_scale_set_draw_value(GTK_SCALE(seekbar),TRUE);
	//gtk_scale_set_value_pos(GTK_SCALE(seekbar),GTK_POS_RIGHT);
	gtk_box_pack_start(GTK_BOX(hbox),seekbar,TRUE,TRUE,5);

	//volumecontrol = gtk_volume_button_new();
	//gtk_box_pack_end(GTK_BOX(hbox),volumecontrol,FALSE,FALSE,5);

	//Adding Status Bar in Window
	statusbar = gtk_statusbar_new();
	gtk_box_pack_end(GTK_BOX(vbox), statusbar, FALSE, TRUE, 1);

	gtk_widget_show_all(mplayer);
	return mplayer;
}
